package com.lesso.cyg.sunflower.controller;

import com.lesso.cyg.sunflower.core.ApiResponse;
import com.lesso.cyg.sunflower.pojo.dto.DatAttendanceRecordDTO;
import com.lesso.cyg.sunflower.service.DatAttendanceRecordService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 员工打卡记录 前端控制器
 */
@RestController
@RequestMapping("/base/employee/attendance/dat-record")
public class DatAttendanceRecordController {

    @DubboReference
    private DatAttendanceRecordService datAttendanceRecordService;

    @PostMapping
    public ApiResponse<String> saveRecord(@Valid @RequestBody DatAttendanceRecordDTO dto) {
        boolean result = datAttendanceRecordService.saveRecord(dto);
        if (result) {
            return ApiResponse.ok("打卡成功");
        } else {
            return ApiResponse.error("打卡失败");
        }
    }
}